package com.itheima.collection;

import java.awt.*;
import java.util.ArrayList;
import java.util.Collection;

public class A02_CollectionDemo02 {
    public static void main(String[] args) {
        //自主创建对象判断在集合中是否存在
        Collection<Student> coll = new ArrayList<>(); //为了练习collection 实际开发不需要

        //创建对象
        Student s1 = new Student("zhangsan", 15);
        Student s2 = new Student("lisi", 14);
        Student s3 = new Student("wangwu", 71);

        //向集合中添加对象
        coll.add(s1);
        coll.add(s2);
        coll.add(s3);

        Student s4 = new Student("zhangsan", 15);
        //判断是否在集合中存在
        //在这里需要重写equals方法 否则则会调用object的equals方法
        boolean result1 = coll.contains(s4);
        System.out.println(result1);
    }
}
